<?php
//公众号参数配置
require_once(dirname(__FILE__).'/../include/config.inc.php');
require_once "jssdk.php";
require_once "function.php";
$appId="wxdd1d67a428b6d912";
$appSecret="3dc7c29cf9ebbd36e90262048cb0dbd2";
$jssdk = new JSSDK($appId, $appSecret);
$openid_str=$_SESSION['openid'];
$g_AccessToken=$jssdk->getAccessToken();
$time=date("Y-m-d H:i:s",time());



$post='{

  "touser": "'.$openid_str.'" ,  

  "template_id": "h5lexxPeUmIA5oAwBMtnIELTO27RC7OugnX7RuCpQJY",    

  "url":"https://www.hanzhibo.cn/wx/user.php",      

  "data": {

      "first": {

          "value": "您好，报修成功，即将派单维修", 

          "color": "#f71b03"

      }, 

      "keyword1": {

          "value": "20171022-1", 

          "color": "#173177"

      }, 

      "keyword2": {

          "value": "'.$time.'", 

          "color": "#173177"

      },

      "keyword3": {

          "value": "教学一体机", 

          "color": "#0e48cb"

      },

      "keyword4": {

          "value": " 郑州市金水区索凌路庙李商务大厦1单元1002", 

          "color": "#173177"

      },

      "keyword5": {

          "value": "开机没有图像", 

          "color": "#173177"

      },

      "remark": {

          "value": "系统正在派单，请稍等。马上会有工程师和您联系，请保持通讯畅通。售后热线：400-888-5607", 

          "color": "#f71b03"

      } 

  }

}';

$json=$post;

//发送消息

if(isset($g_AccessToken)){

	$uuu="https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$g_AccessToken;

	$ch = curl_init();

	curl_setopt($ch, CURLOPT_URL, $uuu);

	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);  //https协议

	curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

	curl_setopt($ch, CURLOPT_POST, 1);

	curl_setopt($ch, CURLOPT_POSTFIELDS, $json);

	$html = curl_exec($ch);

	var_dump($html);

}







?>



